package com.sunnay.constant;

import com.sunnay.exception.DataException;

import java.util.ArrayList;
import java.util.List;

/**
 * @discrption: 静态值常量
 * @user:Gaby
 * @createTime: 2021/1/25 18:47
 */
public class StaticValueConstant {

    public static final String ALL_TEXT = "全部";
    public final static String LOCALHOST_IP = "127.0.0.1";
    public final static String DEFAULT_30 = "30";
    public final static String CUSTOMER_SERVICE_NICKNAME = "平台小二";

    public final static String STATUS_00A = "00A"; //
    public final static String STATUS_00B = "00B";//已下单
    public final static String STATUS_00C = "00C";//已申请取消订单
    public final static String STATUS_00D = "00D";//已发货
    public final static String STATUS_00E = "00E";//
    public final static String STATUS_00F = "00F";//买家发起退货申请

    public final static String STATUS_00FF = "00FF";//卖家同意退货申请

    public final static String STATUS_00I = "00I";//买家退货已发货

    public final static String STATUS_00H = "00H";//订单完成待结算

    public final static String STATUS_00G = "00G";//订单关闭

    public final static String STATUS_00Z = "00Z";//订单关闭

    public final static String STATUS_00ZZ = "00ZZ";//订单完成已结算

    //逗号
    public final static String SYMBOL_COMMA = ",";
    public final static String JPEG_SUFFIX_JPG = ".jpg";
    public final static String JPEG_SUFFIX_PNG = ".png";

    public final static String DEFAULT_JSON_OBJ = "{}";
    public final static String DEFAULT_JSON_ARRAY_OBJ = "[]";

    //默认取1条数据
    public final static String SQL_LIMIT_1 = "LIMIT 1";

    public final static int DAY_OF_SECOND = 60 * 60 * 24;

    public final static Integer SECOND_00 = 0;
    public final static Integer SECOND_23_59=86340;
    public final static Integer SECOND_DAY=86400;

    //最大金额 99万
    public final static Double MAX_MONEY=990000D;
    public final static Long MAX_MONEY_100=99000000L;

    public static final Object DEFAULT_OBJ = new Object();

    public static final String PREFIX_PROJECT_NAME = "gb_";


    /**
     * 时间小时偶数列表
     */
    public final static List<Integer> DAY_HOURS_EVEN_LIST = new ArrayList(13) {{
        add(0);
        add(2);
        add(4);
        add(6);
        add(8);
        add(10);
        add(12);
        add(14);
        add(16);
        add(18);
        add(20);
        add(22);
        add(24);
    }};


    public enum SourceEnum {
        JS_API(1, "微信小程序", "mp_token", "open_id"),
        IOS(2, "苹果系统", "token", "app_open_id"),
        ANDROID(4, "安卓", "token", "app_open_id"),
        WEB(8, "公众号", "web_token", "pub_open_id"),
        H5(16, "H5", "h5_token", "pub_open_id"),
        TOOLS(32, "工具", "tool_token", "pub_open_id"),
        NESTED(64, "嵌套页面", "nested_token", "pub_open_id"),
        BAIDU_MP(128, "百度小程序", "bd_mp_token", "open_id"),
        SOURCE_JS_API(1, "小程序", "", "open_id"),
        SOURCE_APP(6, "APP", "", "app_open_id"),
        SOURCE_PUB(24, "公众号", "", "pub_open_id"),
        SOURCE_EXTERNAL(96, "外部", "", "pub_open_id"),
        PAY_SOURCE_JS_API(1, "JSAPI", "mp_token", "open_id"),
        PAY_SOURCE_APP(6, "APP", "token", "app_open_id"),
        PAY_SOURCE_WEB(8, "JSAPI", "web_token", "pub_open_id"),
        PAY_SOURCE_H5(16, "NATIVE", "h5_token", "pub_open_id"),
        PAY_SOURCE_EXTERNAL(96, "NATIVE", "", "pub_open_id");

        private Integer key;
        private String value;
        private String token;
        private String openId;

        SourceEnum(Integer key, String value, String token, String openId) {
            this.key = key;
            this.value = value;
            this.token = token;
            this.openId = openId;
        }

        public Integer getKey() {
            return key;
        }

        public void setKey(Integer key) {
            this.key = key;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getToken() {
            return token;
        }

        public void setToken(String token) {
            this.token = token;
        }

        public String getOpenId() {
            return openId;
        }

        public void setOpenId(String openId) {
            this.openId = openId;
        }

        public static SourceEnum getEnum(Integer key) {
            if (key == null) {
                throw new DataException("未支持该来源类型");
            } else {
                switch (key) {
                    case 1:
                        return JS_API;
                    case 2:
                        return IOS;
                    case 4:
                        return ANDROID;
                    case 8:
                        return WEB;
                    case 16:
                        return H5;
                    case 32:
                        return TOOLS;
                    case 64:
                        return NESTED;
                    case 128:
                        return BAIDU_MP;
                    default:
                        throw new DataException("未支持该类型");
                }
            }
        }

        public static SourceEnum getPaySource(Integer key) {
            if (key == null) {
                throw new DataException("无法识别支付来源,请联系客服后操作");
            } else if ((PAY_SOURCE_JS_API.getKey() & key) > 0) {
                return PAY_SOURCE_JS_API;
            } else if ((PAY_SOURCE_APP.getKey() & key) > 0) {
                return PAY_SOURCE_APP;
            } else if ((PAY_SOURCE_WEB.getKey() & key) > 0) {
                return PAY_SOURCE_WEB;
            } else if ((PAY_SOURCE_H5.getKey() & key) > 0) {
                return PAY_SOURCE_H5;
            } else if ((PAY_SOURCE_EXTERNAL.getKey() & key) > 0) {
                return PAY_SOURCE_EXTERNAL;
            } else if ((BAIDU_MP.getKey() & key) > 0) {
                return BAIDU_MP;
            } else {
                throw new DataException("无法识别支付来源,请联系客服后操作");
            }
        }

        public static boolean isApp(Integer client) {
            if (client == null) {
                throw new DataException("未支持该来源类型");
            } else {
                return (PAY_SOURCE_APP.getKey() & client) > 0;
            }
        }
    }


    /**
     * @discrption: 系统类型枚举
     * @user:Gaby
     * @createTime: 2020/7/4 11:38
     */
    public enum SystemTypeEnum {
        PERSON(32,"个人电商平台");

        public final static String SYSTEM_TYPE_STR = "systemType";

        private Integer key;
        private String value;

        SystemTypeEnum(Integer key, String value) {
            this.key = key;
            this.value = value;
        }

        public Integer getKey() {
            return key;
        }

        public void setKey(Integer key) {
            this.key = key;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public static SystemTypeEnum getEnum(Integer systemType) {
            if (systemType == null) {
                throw new DataException("暂不支持该系统类型");
            }
            switch (systemType) {
                case 32:
                    return PERSON;
                default:
                    throw new DataException("暂不支持该系统类型");
            }
        }
    }

    /**
     * 系统设置类型枚举
     */
    public enum SettingTypeEnum{
        MAKE_MONEY_STRATEGY(1,"赚钱攻略文字"),
        NEW_PERSON_COUPON_ALERT(2,"新人优惠券弹窗"),
        REMOVE_TEMP_BIND(3,"解除临时绑定时间"),
        COUPON_NEW_TAKE_TEXT(4,"新人优惠券领取文本"),
        SUPPLIER_RECOMMEND_EXPIRE(5,"卖家推荐人失效时间"),
        DEFAULT_LOGO(6,"平台默认logo图"),
        DEFAULT_SHARE_IMAGE(7,"分享默认图"),
        SHARE_TEXT_BG_IMAGE(8,"分享文字背景图"),
        HEADIMG_BACK_PLATE(9,"头像挡板"),
        SUBSIDY_ACTIVITY_TITLE(10,"补贴活动标题"),
        ALL_SUPPLIER_TO_STORE_VIEW(11,"所有商家对超级仓库可见"),
        GOODS_SHARE_BACKGROUND_IMAGE(12,"商品分享背景图"),
        GOODS_COMPUTE_WEIGHT_CYCLE(13,"商品计算权重周期");

        private Integer key;

        private String value;

        SettingTypeEnum(Integer key,String value){
            this.key = key;
            this.value = value;
        }

        public Integer getKey() {
            return key;
        }

        public void setKey(Integer key) {
            this.key = key;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }

    public enum BanDelPicTypeEnum{
        ORDER(1,"订单"),
        COMMODITY_CODE_PRODUCT(2,"条形码产品"),
        HEAD_IMG(3,"修改头像"),
        STORE_IMG(4,"超级仓库商品");

        private Integer key;

        private String value;

        BanDelPicTypeEnum(Integer key,String value){
            this.key = key;
            this.value =value;
        }

        public Integer getKey() {
            return key;
        }

        public void setKey(Integer key) {
            this.key = key;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }
}
